---
title: Google Serper
---

This notebook goes over how to use the `Google Serper` component to search the web. First you need to sign up for a free account at [serper.dev](https://serper.dev) and get your api key.

```python
%pip install -qU  langchain-community langchain-openai
```

```python
import os
import pprint

os.environ["SERPER_API_KEY"] = "your-serper-api-key"
```

```python
from langchain_community.utilities import GoogleSerperAPIWrapper

search = GoogleSerperAPIWrapper()
```

```python
search.run("Obama's first name?")
```

```output
'Barack Hussein Obama II'
```

## As part of a Self Ask With Search Agent

In order to create an agent that uses the Google Serper tool install LangGraph

```python
%pip install -qU langgraph langchain-openai
```

and use the `create_agent` functionality to initialize a ReAct agent. You will also need to set up your OPENAI_API_KEY (visit [platform.openai.com](https://platform.openai.com)) in order to access OpenAI's chat models.

```python
from langchain.chat_models import init_chat_model
from langchain_community.utilities import GoogleSerperAPIWrapper
from langchain_core.tools import Tool
from langchain.agents import create_agent

os.environ["OPENAI_API_KEY"] = "[your openai key]"

llm = init_chat_model("gpt-4o-mini", model_provider="openai", temperature=0)
search = GoogleSerperAPIWrapper()
tools = [
    Tool(
        name="Intermediate_Answer",
        func=search.run,
        description="useful for when you need to ask with search",
    )
]
agent = create_agent(llm, tools)

events = agent.stream(
    {
        "messages": [
            ("user", "What is the hometown of the reigning men's U.S. Open champion?")
        ]
    },
    stream_mode="values",
)

for event in events:
    event["messages"][-1].pretty_print()
```

## Obtaining results with metadata

If you would also like to obtain the results in a structured way including metadata. For this we will be using the `results` method of the wrapper.

```python
search = GoogleSerperAPIWrapper()
results = search.results("Apple Inc.")
pprint.pp(results)
```

```output
{'searchParameters': {'q': 'Apple Inc.',
                      'gl': 'us',
                      'hl': 'en',
                      'type': 'search',
                      'num': 10,
                      'engine': 'google'},
 'knowledgeGraph': {'title': 'Apple',
                    'type': 'Technology company',
                    'website': 'http://www.apple.com/',
                    'imageUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT5ITHsQzdzkkFWKinRe1Y4FUbC_Vy3R_M&s=0',
                    'description': 'Apple Inc. is an American multinational '
                                   'corporation and technology company '
                                   'headquartered in Cupertino, California, in '
                                   'Silicon Valley. It is best known for its '
                                   'consumer electronics, software, and '
                                   'services.',
                    'descriptionSource': 'Wikipedia',
                    'descriptionLink': 'https://en.wikipedia.org/wiki/Apple_Inc.',
                    'attributes': {'Customer service': '1 (800) 275-2273',
                                   'Founders': 'Steve Jobs, Steve Wozniak, and '
                                               'Ronald Wayne',
                                   'Founded': 'April 1, 1976, Los Altos, CA',
                                   'Headquarters': 'Cupertino, CA',
                                   'CEO': 'Tim Cook (Aug 24, 2011–)'}},
 'organic': [{'title': 'Apple',
              'link': 'https://www.apple.com/',
              'snippet': 'Discover the innovative world of Apple and shop '
                         'everything iPhone, iPad, Apple Watch, Mac, and Apple '
                         'TV, plus explore accessories, entertainment, ...',
              'sitelinks': [{'title': 'Career Opportunities',
                             'link': 'https://www.apple.com/careers/us/'},
                            {'title': 'Support',
                             'link': 'https://support.apple.com/'},
                            {'title': 'Investor Relations',
                             'link': 'https://investor.apple.com/investor-relations/default.aspx'},
                            {'title': 'Apple Leadership',
                             'link': 'https://www.apple.com/leadership/'},
                            {'title': 'Store',
                             'link': 'https://www.apple.com/store'}],
              'position': 1},
             {'title': 'Apple Inc. - Wikipedia',
              'link': 'https://en.wikipedia.org/wiki/Apple_Inc.',
              'snippet': 'Apple Inc. is an American multinational corporation '
                         'and technology company headquartered in Cupertino, '
                         'California, in Silicon Valley. It is best known for '
                         '...',
              'position': 2},
             {'title': 'Apple Inc. (AAPL) Stock Price Today - WSJ',
              'link': 'https://www.wsj.com/market-data/quotes/AAPL',
              'snippet': 'Apple Inc. engages in the design, manufacture, and '
                         'sale of smartphones, personal computers, tablets, '
                         'wearables and accessories, and other varieties of '
                         'related ...',
              'position': 3},
             {'title': 'Apple Inc. | History, Products, Headquarters, & Facts '
                       '- Britannica',
              'link': 'https://www.britannica.com/money/Apple-Inc',
              'snippet': 'American manufacturer of personal computers, '
                         'smartphones, and tablet computers. Apple was the '
                         'first successful personal computer company and ...',
              'date': '5 days ago',
              'position': 4},
             {'title': 'Apple Inc. (AAPL) Company Profile & Facts - Yahoo '
                       'Finance',
              'link': 'https://finance.yahoo.com/quote/AAPL/profile/',
              'snippet': 'See the company profile for Apple Inc. (AAPL) '
                         'including business summary, industry/sector '
                         'information, number of employees, business summary, '
                         '...',
              'position': 5},
             {'title': 'AAPL: Apple Inc Stock Price Quote - NASDAQ GS - '
                       'Bloomberg',
              'link': 'https://www.bloomberg.com/quote/AAPL:US',
              'snippet': 'Apple Inc. designs, manufactures, and markets '
                         'smartphones, personal computers, tablets, wearables '
                         'and accessories, and sells a variety of related '
                         'accessories.',
              'position': 6}],
 'images': [{'title': 'Apple Inc. - Wikipedia',
             'imageUrl': 'https://upload.wikimedia.org/wikipedia/commons/f/fa/Apple_logo_black.svg',
             'link': 'https://en.wikipedia.org/wiki/Apple_Inc.'},
            {'title': 'Apple Inc. - Wikipedia',
             'imageUrl': 'https://upload.wikimedia.org/wikipedia/commons/thumb/5/5a/Aerial_view_of_Apple_Park_dllu.jpg/330px-Aerial_view_of_Apple_Park_dllu.jpg',
             'link': 'https://en.wikipedia.org/wiki/Apple_Inc.'},
            {'title': 'Apple',
             'imageUrl': 'https://www.apple.com/ac/structured-data/images/open_graph_logo.png?202110180743',
             'link': 'https://www.apple.com/'},
            {'title': 'Apple Store - Find a Store - Apple',
             'imageUrl': 'https://rtlimages.apple.com/cmc/dieter/store/16_9/R289.png?resize=672:378&output-format=jpg&output-quality=85&interpolation=progressive-bicubic',
             'link': 'https://www.apple.com/retail/'},
            {'title': 'Apple | LinkedIn',
             'imageUrl': 'https://media.licdn.com/dms/image/v2/C560BAQHdAaarsO-eyA/company-logo_200_200/company-logo_200_200/0/1630637844948/apple_logo?e=2147483647&v=beta&t=pOXzU29XHyAnHt2zp2JryxZvMBdKpqxkkbDWtZ_pnEk',
             'link': 'https://www.linkedin.com/company/apple'},
            {'title': 'The Founding of Apple Computer, Inc. - This Month in '
                      'Business ...',
             'imageUrl': 'https://tile.loc.gov/storage-services/service/pnp/highsm/49100/49193r.jpg',
             'link': 'https://guides.loc.gov/this-month-in-business-history/april/apple-computer-founded'},
            {'title': 'Apple Inc. (AAPL) Stock Price, News, Quote & History - '
                      'Yahoo Finance',
             'imageUrl': 'https://s.yimg.com/uu/api/res/1.2/wsqdHHH05iioDnVbAb2WPQ--~B/aD01NzY7dz0xMDI0O2FwcGlkPXl0YWNoeW9u/https://media.zenfs.com/en/Benzinga/8f4e6ec4860c044f97cc63cfdd74b4f2.cf.webp',
             'link': 'https://finance.yahoo.com/quote/AAPL/'},
            {'title': 'Apple Store - Find a Store - Apple',
             'imageUrl': 'https://rtlimages.apple.com/cmc/dieter/store/16_9/R219.png?resize=672:378&output-format=jpg&output-quality=85&interpolation=progressive-bicubic',
             'link': 'https://www.apple.com/retail/'},
            {'title': 'Apple Store - Find a Store - Apple',
             'imageUrl': 'https://rtlimages.apple.com/cmc/dieter/store/16_9/R420.png?resize=672:378&output-format=jpg&output-quality=85&interpolation=progressive-bicubic',
             'link': 'https://www.apple.com/retail/'}],
 'peopleAlsoAsk': [{'question': 'What is the Apple Inc?',
                    'snippet': 'It is best known for its consumer electronics, '
                               'software, and services. Founded in 1976 as '
                               'Apple Computer Company by Steve Jobs, Steve '
                               'Wozniak and Ronald Wayne, the company was '
                               'incorporated by Jobs and Wozniak as Apple '
                               'Computer, Inc. the following year. It was '
                               'renamed Apple Inc.',
                    'title': 'Apple Inc. - Wikipedia',
                    'link': 'https://en.wikipedia.org/wiki/Apple_Inc.'},
                   {'question': 'Is Apple an LLC or Inc.?',
                    'snippet': 'Apple Inc., located at One Apple Park Way, '
                               'Cupertino, California, for users in the United '
                               'States, including Puerto Rico.',
                    'title': 'Legal - Privacy Policy Affiliated Company - '
                             'Apple',
                    'link': 'https://www.apple.com/legal/privacy/en-ww/affiliated-company/'}],
 'relatedSearches': [{'query': 'apple inc คืออะไร'},
                     {'query': 'Apple Inc full form'},
                     {'query': 'Apple Inc address'},
                     {'query': 'Apple Inc investor relations'},
                     {'query': 'Apple Inc industry'},
                     {'query': 'Apple Inc careers'},
                     {'query': 'Apple Inc Net worth'}],
 'credits': 1}
```

## Searching for Google Images

We can also query Google Images using this wrapper. For example:

```python
search = GoogleSerperAPIWrapper(type="images")
results = search.results("Lion")
pprint.pp(results)
```

```output
{'searchParameters': {'q': 'Lion',
                      'gl': 'us',
                      'hl': 'en',
                      'type': 'images',
                      'num': 10,
                      'engine': 'google'},
 'images': [{'title': 'Lion - Wikipedia',
             'imageUrl': 'https://upload.wikimedia.org/wikipedia/commons/a/a6/020_The_lion_king_Snyggve_in_the_Serengeti_National_Park_Photo_by_Giles_Laurent.jpg',
             'imageWidth': 5168,
             'imageHeight': 3448,
             'thumbnailUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR_HGdbfaRDdKJpWDDdD0AkS58dHashCEbqH9yTMz4j7lQIC6iD&s',
             'thumbnailWidth': 275,
             'thumbnailHeight': 183,
             'source': 'Wikipedia',
             'domain': 'en.wikipedia.org',
             'link': 'https://en.wikipedia.org/wiki/Lion',
             'googleUrl': 'https://www.google.com/imgres?imgurl=https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2Fa%2Fa6%2F020_The_lion_king_Snyggve_in_the_Serengeti_National_Park_Photo_by_Giles_Laurent.jpg&tbnid=iu_QQ3Z8fGxRvM&imgrefurl=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FLion&docid=0P9ZPIi_HU4dMM&w=5168&h=3448&ved=0ahUKEwjl5-H3hfmMAxUMvokEHY6wD3gQvFcIAigA',
             'position': 1},
            {'title': 'Lion | Characteristics, Habitat, & Facts | Britannica',
             'imageUrl': 'https://cdn.britannica.com/29/150929-050-547070A1/lion-Kenya-Masai-Mara-National-Reserve.jpg',
             'imageWidth': 1600,
             'imageHeight': 1085,
             'thumbnailUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSCqaKY_THr0IBZN8c-2VApnnbuvKmnsWjfrwKoWHFR9w3eN5o&s',
             'thumbnailWidth': 273,
             'thumbnailHeight': 185,
             'source': 'Britannica',
             'domain': 'www.britannica.com',
             'link': 'https://www.britannica.com/animal/lion',
             'googleUrl': 'https://www.google.com/imgres?imgurl=https%3A%2F%2Fcdn.britannica.com%2F29%2F150929-050-547070A1%2Flion-Kenya-Masai-Mara-National-Reserve.jpg&tbnid=DBk5Qx3rVV587M&imgrefurl=https%3A%2F%2Fwww.britannica.com%2Fanimal%2Flion&docid=Zp2R2-BbubSvqM&w=1600&h=1085&ved=0ahUKEwjl5-H3hfmMAxUMvokEHY6wD3gQvFcIAygB',
             'position': 2},
            {'title': 'Lion',
             'imageUrl': 'https://i.natgeofe.com/k/1d33938b-3d02-4773-91e3-70b113c3b8c7/lion-male-roar.jpg?wp=1&w=1084.125&h=609',
             'imageWidth': 1083,
             'imageHeight': 609,
             'thumbnailUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQDDPsOQpmuAhyuNY28gdM0msnIfqxIlLi01CudMaojO5w0xmM&s',
             'thumbnailWidth': 300,
             'thumbnailHeight': 168,
             'source': 'National Geographic Kids',
             'domain': 'kids.nationalgeographic.com',
             'link': 'https://kids.nationalgeographic.com/animals/mammals/facts/lion',
             'googleUrl': 'https://www.google.com/imgres?imgurl=https%3A%2F%2Fi.natgeofe.com%2Fk%2F1d33938b-3d02-4773-91e3-70b113c3b8c7%2Flion-male-roar.jpg%3Fwp%3D1%26w%3D1084.125%26h%3D609&tbnid=P9Vzzl57Ow4obM&imgrefurl=https%3A%2F%2Fkids.nationalgeographic.com%2Fanimals%2Fmammals%2Ffacts%2Flion&docid=r48PKzcCogU0oM&w=1083&h=609&ved=0ahUKEwjl5-H3hfmMAxUMvokEHY6wD3gQvFcIBCgC',
             'position': 3},
            {'title': 'Lion | Characteristics, Habitat, & Facts | Britannica',
             'imageUrl': 'https://cdn.britannica.com/30/150930-120-D3D93F1E/lion-panthea-leo-Namibia.jpg',
             'imageWidth': 900,
             'imageHeight': 675,
             'thumbnailUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRYxxLBZ8F_59YdYFJu6y8Zfhf64kMNbrD94uNF0gj9Wgtr4B2k&s',
             'thumbnailWidth': 259,
             'thumbnailHeight': 194,
             'source': 'Britannica',
             'domain': 'www.britannica.com',
             'link': 'https://www.britannica.com/animal/lion',
             'googleUrl': 'https://www.google.com/imgres?imgurl=https%3A%2F%2Fcdn.britannica.com%2F30%2F150930-120-D3D93F1E%2Flion-panthea-leo-Namibia.jpg&tbnid=gu4-4upZHrFJ5M&imgrefurl=https%3A%2F%2Fwww.britannica.com%2Fanimal%2Flion&docid=Zp2R2-BbubSvqM&w=900&h=675&ved=0ahUKEwjl5-H3hfmMAxUMvokEHY6wD3gQvFcIBSgD',
             'position': 4},
            {'title': '6,800+ Lion Walking Stock Photos, Pictures & '
                      'Royalty-Free Images ...',
             'imageUrl': 'https://media.istockphoto.com/id/877369086/photo/lion-panthera-leo-10-years-old-isolated-on-white.jpg?s=612x612&w=0&k=20&c=J__Jx_BX_FN7iehO965TJtPFYUl0A-bwFgIYaK32R3Y=',
             'imageWidth': 612,
             'imageHeight': 527,
             'thumbnailUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQNXCI7damJui7Vvf6TQi0ixg_kgvbGQcl9L01u4Rx6ZCI7lqyR&s',
             'thumbnailWidth': 242,
             'thumbnailHeight': 208,
             'source': 'iStock',
             'domain': 'www.istockphoto.com',
             'link': 'https://www.istockphoto.com/photos/lion-walking',
             'googleUrl': 'https://www.google.com/imgres?imgurl=https%3A%2F%2Fmedia.istockphoto.com%2Fid%2F877369086%2Fphoto%2Flion-panthera-leo-10-years-old-isolated-on-white.jpg%3Fs%3D612x612%26w%3D0%26k%3D20%26c%3DJ__Jx_BX_FN7iehO965TJtPFYUl0A-bwFgIYaK32R3Y%3D&tbnid=UbVNtrUwB3qvSM&imgrefurl=https%3A%2F%2Fwww.istockphoto.com%2Fphotos%2Flion-walking&docid=VUUNuYLgdvat6M&w=612&h=527&ved=0ahUKEwjl5-H3hfmMAxUMvokEHY6wD3gQvFcIBigE',
             'creator': 'GlobalP',
             'credit': 'Getty Images/iStockphoto',
             'position': 5},
            {'title': 'Free Fierce Lion Roaring Image | Download at StockCake',
             'imageUrl': 'https://images.stockcake.com/public/6/d/2/6d2a992e-cf12-460f-a811-c961e124d9a2_large/fierce-lion-roaring-stockcake.jpg',
             'imageWidth': 408,
             'imageHeight': 728,
             'thumbnailUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRDLNUIqFT5oEh7CNtksHhODRWcuCYkwjHI-sLQXaV4rCPbcO8R&s',
             'thumbnailWidth': 168,
             'thumbnailHeight': 300,
             'source': 'StockCake',
             'domain': 'stockcake.com',
             'link': 'https://stockcake.com/i/fierce-lion-roaring_1358116_1064655',
             'googleUrl': 'https://www.google.com/imgres?imgurl=https%3A%2F%2Fimages.stockcake.com%2Fpublic%2F6%2Fd%2F2%2F6d2a992e-cf12-460f-a811-c961e124d9a2_large%2Ffierce-lion-roaring-stockcake.jpg&tbnid=14Bc2UcRYg2vRM&imgrefurl=https%3A%2F%2Fstockcake.com%2Fi%2Ffierce-lion-roaring_1358116_1064655&docid=mIUgDyGFaSvxJM&w=408&h=728&ved=0ahUKEwjl5-H3hfmMAxUMvokEHY6wD3gQvFcIBygF',
             'position': 6},
            {'title': 'Lion | Characteristics, Habitat, & Facts | Britannica',
             'imageUrl': 'https://cdn.britannica.com/55/2155-050-604F5A4A/lion.jpg',
             'imageWidth': 754,
             'imageHeight': 752,
             'thumbnailUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS3fnDub1GSojI0hJ-ZGS8Tv-hkNNloXh98DOwXZoZ_nUs3GWSd&s',
             'thumbnailWidth': 225,
             'thumbnailHeight': 224,
             'source': 'Britannica',
             'domain': 'www.britannica.com',
             'link': 'https://www.britannica.com/animal/lion',
             'googleUrl': 'https://www.google.com/imgres?imgurl=https%3A%2F%2Fcdn.britannica.com%2F55%2F2155-050-604F5A4A%2Flion.jpg&tbnid=IhlRPXpsi9aDnM&imgrefurl=https%3A%2F%2Fwww.britannica.com%2Fanimal%2Flion&docid=Zp2R2-BbubSvqM&w=754&h=752&ved=0ahUKEwjl5-H3hfmMAxUMvokEHY6wD3gQvFcICCgG',
             'position': 7},
            {'title': "Bringing Nigeria's lion population back from extinction "
                      '- WildAid',
             'imageUrl': 'https://wildaid.org/wp-content/uploads/2022/08/Untitled-design-32-400x335.png',
             'imageWidth': 400,
             'imageHeight': 335,
             'thumbnailUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTnurDJfi5sllJxVxWFjfyU8nvXqxy3ef2dcxUTNBmLND9aVuQ&s',
             'thumbnailWidth': 245,
             'thumbnailHeight': 205,
             'source': '- WildAid',
             'domain': 'wildaid.org',
             'link': 'https://wildaid.org/bringing-nigerias-lion-population-back-from-extinction/',
             'googleUrl': 'https://www.google.com/imgres?imgurl=https%3A%2F%2Fwildaid.org%2Fwp-content%2Fuploads%2F2022%2F08%2FUntitled-design-32-400x335.png&tbnid=ri5ErxfeVw-rUM&imgrefurl=https%3A%2F%2Fwildaid.org%2Fbringing-nigerias-lion-population-back-from-extinction%2F&docid=IRE1bqPePPGKUM&w=400&h=335&ved=0ahUKEwjl5-H3hfmMAxUMvokEHY6wD3gQvFcICSgH',
             'position': 8},
            {'title': 'Lion',
             'imageUrl': 'https://images.photowall.com/products/46596/lion-1.jpg?h=699&q=85',
             'imageWidth': 699,
             'imageHeight': 699,
             'thumbnailUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTT-SMMS4_tLzeHGP8iK6q1f6VuAfAGKuwvRcKhfAmt6GEutoRZ&s',
             'thumbnailWidth': 225,
             'thumbnailHeight': 225,
             'source': 'Photowall',
             'domain': 'www.photowall.com',
             'link': 'https://www.photowall.com/us/lion-1-poster',
             'googleUrl': 'https://www.google.com/imgres?imgurl=https%3A%2F%2Fimages.photowall.com%2Fproducts%2F46596%2Flion-1.jpg%3Fh%3D699%26q%3D85&tbnid=Hx0R3srHGe7c6M&imgrefurl=https%3A%2F%2Fwww.photowall.com%2Fus%2Flion-1-poster&docid=svxN-CF1BznYSM&w=699&h=699&ved=0ahUKEwjl5-H3hfmMAxUMvokEHY6wD3gQvFcICigI',
             'position': 9},
            {'title': 'Lion | Species | WWF',
             'imageUrl': 'https://files.worldwildlife.org/wwfcmsprod/images/Lion_Kenya/story_full_width/92n0a30duq_Medium_WW2116702.jpg',
             'imageWidth': 1000,
             'imageHeight': 600,
             'thumbnailUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQcAAjEbm00R6g4382D54syoBUFN19j80OBd31FAOMwK_S2Pa9d&s',
             'thumbnailWidth': 290,
             'thumbnailHeight': 174,
             'source': 'World Wildlife Fund',
             'domain': 'www.worldwildlife.org',
             'link': 'https://www.worldwildlife.org/species/lion--19',
             'googleUrl': 'https://www.google.com/imgres?imgurl=https%3A%2F%2Ffiles.worldwildlife.org%2Fwwfcmsprod%2Fimages%2FLion_Kenya%2Fstory_full_width%2F92n0a30duq_Medium_WW2116702.jpg&tbnid=N9k7RywguCeZmM&imgrefurl=https%3A%2F%2Fwww.worldwildlife.org%2Fspecies%2Flion--19&docid=RqCpf1UYcQDKxM&w=1000&h=600&ved=0ahUKEwjl5-H3hfmMAxUMvokEHY6wD3gQvFcICygJ',
             'copyright': 'Juozas Cernius',
             'creator': 'Juozas Cernius www.CERNIUS.com',
             'position': 10}],
 'credits': 1}
```

## Searching for Google News

We can also query Google News using this wrapper. For example:

```python
search = GoogleSerperAPIWrapper(type="news")
results = search.results("Tesla Inc.")
pprint.pp(results)
```

```output
{'searchParameters': {'q': 'Tesla Inc.',
                      'gl': 'us',
                      'hl': 'en',
                      'type': 'news',
                      'num': 10,
                      'engine': 'google'},
 'news': [{'title': 'Tesla stock soars after DoT unveils new self-driving car '
                    'rules, set for near-20% weekly rally',
           'link': 'https://finance.yahoo.com/news/tesla-stock-soars-after-dot-unveils-new-self-driving-car-rules-set-for-near-20-weekly-rally-183748972.html',
           'snippet': 'Tesla (TSLA) stock surged as much as 10% on Friday, '
                      'putting shares on track to log a weekly gain north of '
                      '17% with several positive...',
           'date': '2 days ago',
           'source': 'Yahoo Finance',
           'imageUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTgHH9x2YIdRGyo1VpJC8b5sYrW5-UprLRAT3r4LQDYx1lX1DeNlunoU4mc2w&s',
           'position': 1},
          {'title': 'Tesla Refunds Early India Bookings Signaling Entry Is '
                    'Near',
           'link': 'https://www.bloomberg.com/news/articles/2025-04-25/tesla-tsla-refunds-early-india-bookings-signaling-entry-is-near',
           'snippet': "Tesla Inc.'s India office is refunding early bookers of "
                      'its Model 3, according to emails seen by Bloomberg '
                      'News, sparking speculation the...',
           'date': '1 day ago',
           'source': 'Bloomberg.com',
           'imageUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTme3lE48FWOyFuWDM-o3wZISjba30aHdoRluMkt7zqlrYqCKK5qGZnwbJ89g&s',
           'position': 2},
          {'title': 'Musk needs to become a more normal CEO',
           'link': 'https://www.ft.com/content/4d10da88-5a0b-49b5-9b29-77286f1985ec',
           'snippet': 'And Tesla should become a more normal company.',
           'date': '10 hours ago',
           'source': 'Financial Times',
           'imageUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSbfTHj0V4haC2VU_bI6W_ZNegrScrmvbUrnkjvskZBzvpPh7WzBIjir342Gw&s',
           'position': 3},
          {'title': "Tesla: The 'Musk Put' Is In Play (NASDAQ:TSLA)",
           'link': 'https://seekingalpha.com/article/4778551-tesla-musk-put-in-play',
           'snippet': "Tesla: The 'Musk Put' Is In Play. Apr. 27, 2025 6:02 AM "
                      'ETTesla, Inc. (TSLA) Stock, TSLA:CA StockBYDDF, NIO, '
                      'XPEV, GOOG, TSLA, TSLA:CA13 Comments 1 Like.',
           'date': '10 hours ago',
           'source': 'Seeking Alpha',
           'imageUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSumMVfOINSI7Xip8Z-wLXwg4mpTuryAk4RMJDL-tWTW5DAdi1yR2WVIezaVQ&s',
           'position': 4},
          {'title': 'Tesla: US Federal Autonomous Vehicle Regulatory Framework '
                    'Aligns With Our Thesis',
           'link': 'https://www.morningstar.com/stocks/tesla-us-federal-autonomous-vehicle-regulatory-framework-aligns-with-our-thesis',
           'snippet': "Editor's Note: This analysis was originally published "
                      'as a stock note by Morningstar Equity Research. '
                      'Securities In This Article. Tesla Inc.',
           'date': '1 day ago',
           'source': 'Morningstar',
           'imageUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT_C3JjwfGXEpLowp-cmCMpxTvoMQ3nmOrhya0aLsnIEBrQSorBX3OSCb1svg&s',
           'position': 5},
          {'title': "Elon Musk's Wealth Skyrockets By Billions As Tesla Stock "
                    'Rallies After Billionaire CEO Steps Back From DOGE',
           'link': 'https://www.benzinga.com/markets/25/04/44974342/elon-musks-wealth-skyrockets-by-billions-as-tesla-stock-rallies-after-billionaire-ceo-steps-back-from-doge',
           'snippet': 'The net worth of Elon Musk witnessed a staggering '
                      'increase of $7.5 billion on Wednesday as shares of '
                      'Tesla Inc. (NASDAQ: TSLA) experienced a...',
           'date': '3 days ago',
           'source': 'Benzinga',
           'imageUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTok4iKaGss1or69QeOrnUo8ZEprpI5Etbq6kepYjLBPlIjOOhiX8yRYWeIiw&s',
           'position': 6},
          {'title': 'Why Tesla Inc. (TSLA) Soared Last Week',
           'link': 'https://finance.yahoo.com/news/why-tesla-inc-tsla-soared-180528904.html',
           'snippet': 'We recently published a list of Why These 10 Firms '
                      'Recorded Double-Digit Gains Last Week. In this article, '
                      'we are going to take a look at...',
           'date': '1 day ago',
           'source': 'Yahoo Finance',
           'imageUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTkQBI72ZwZ8mNhFQ58DLH4wJMyfpsA67ONuTDvvOfAjop5kTrOVcymDGairw&s',
           'position': 7},
          {'title': 'Tesla Hikes Canadian Prices and Pushes Its Pre-Tariff '
                    'Inventory',
           'link': 'https://www.bloomberg.com/news/articles/2025-04-26/tesla-hikes-canadian-prices-and-pushes-its-pre-tariff-inventory',
           'snippet': 'Tesla Inc. is raising prices in Canada and encouraging '
                      'buyers to snap up cars imported before counter-tariffs '
                      'were imposed on US-made...',
           'date': '1 day ago',
           'source': 'Bloomberg.com',
           'imageUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ3pUCdm4COUa4ckj6l-_oqzQUQyPZ_TwxylDHsKfQ5OHaTeC5C14xi3xTPjw&s',
           'position': 8},
          {'title': 'Tesla, Inc. (TSLA) Faces Weak Q1 Auto Revenues but '
                    'Stresses Long-Term AI and Robotics Vision',
           'link': 'https://finance.yahoo.com/news/tesla-inc-tsla-faces-weak-142059117.html',
           'snippet': 'We recently compiled a list of the 12 AI Stocks '
                      'Analysts Are Talking About Right Now. In this article, '
                      'we are going to take a look at where...',
           'date': '1 day ago',
           'source': 'Yahoo Finance',
           'imageUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQAF15LDx0VBN7Yhpe99fDywZVZOe2rC4QAQgOyIXyRMMEbUURh_ujyCqQHQg&s',
           'position': 9},
          {'title': 'Analyst Says Tesla (TSLA) Valuation Still ‘Incredibly '
                    'Rich’ as Chinese Companies ‘Eat’ Its Market Share',
           'link': 'https://finance.yahoo.com/news/analyst-says-tesla-tsla-valuation-183703204.html',
           'snippet': 'We recently published a list of Top 10 Stocks to Watch '
                      'Ahead of May. In this article, we are going to take a '
                      'look at where Tesla, Inc.',
           'date': '2 hours ago',
           'source': 'Yahoo Finance',
           'imageUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTd5uofRE66VcJeA46Ewvop5DmICfn3q1dYjk7QydsDVIp12Qtn4rTtzQJJ4g&s',
           'position': 10}],
 'credits': 1}
```

If you want to only receive news articles published in the last hour, you can do the following:

```python
search = GoogleSerperAPIWrapper(type="news", tbs="qdr:h")
results = search.results("Tesla Inc.")
pprint.pp(results)
```

```output
{'searchParameters': {'q': 'Tesla Inc.',
                      'gl': 'us',
                      'hl': 'en',
                      'type': 'news',
                      'num': 10,
                      'tbs': 'qdr:h',
                      'engine': 'google'},
 'news': [{'title': 'Big Tech faces high-stakes earnings week amid tariff '
                    'jitters',
           'link': 'https://seekingalpha.com/news/4436090-big-tech-faces-high-stakes-earnings-week-amid-tariff-jitters',
           'snippet': 'When Big Tech last reported earnings, President Donald '
                      'Trump had just taken office, optimism over a pro-growth '
                      'agenda was fueling a stock rally and...',
           'date': '3 minutes ago',
           'source': 'Seeking Alpha',
           'imageUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ9sc9IB67rgImvp7XEOuMDzLhJ6uj7-kNRp6vCShZ7Z9KzDqAR2OeKyHeKvg&s',
           'position': 1}],
 'credits': 1}
```

Some examples of the `tbs` parameter:

`qdr:h` (past hour)
`qdr:d` (past day)
`qdr:w` (past week)
`qdr:m` (past month)
`qdr:y` (past year)

You can specify intermediate time periods by adding a number:
`qdr:h12` (past 12 hours)
`qdr:d3` (past 3 days)
`qdr:w2` (past 2 weeks)
`qdr:m6` (past 6 months)
`qdr:y2` (past 2 years)

For all supported filters simply go to [Google Search](https://google.com), search for something, click on "Tools", add your date filter and check the URL for "tbs=".

## Searching for Google Places

We can also query Google Places using this wrapper. For example:

```python
search = GoogleSerperAPIWrapper(type="places")
results = search.results("Italian restaurants in Upper East Side")
pprint.pp(results)
```

```output
{'searchParameters': {'q': 'Italian restaurants in Upper East Side',
                      'gl': 'us',
                      'hl': 'en',
                      'type': 'places',
                      'num': 10,
                      'engine': 'google'},
 'places': [{'position': 1,
             'title': "Tony's Di Napoli",
             'address': '1081 3rd Ave, New York, NY 10065',
             'latitude': 40.7643567,
             'longitude': -73.9642373,
             'rating': 4.6,
             'ratingCount': 2900,
             'priceLevel': '$$',
             'category': 'Italian restaurant',
             'phoneNumber': '(212) 888-6333',
             'website': 'http://www.tonysnyc.com/',
             'cid': '1820798058748048984'},
            {'position': 2,
             'title': "L'Osteria",
             'address': '1219 Lexington Ave, New York, NY 10028',
             'latitude': 40.7771565,
             'longitude': -73.9571345,
             'rating': 4.7,
             'ratingCount': 268,
             'priceLevel': '$30–50',
             'category': 'Italian restaurant',
             'phoneNumber': '(646) 524-6294',
             'website': 'http://www.losterianyc.com/',
             'cid': '13046004590297227899'},
            {'position': 3,
             'title': 'La Pecora Bianca UES',
             'address': '1562 2nd Ave, New York, NY 10028',
             'latitude': 40.7746814,
             'longitude': -73.9538665,
             'rating': 4.8,
             'ratingCount': 1300,
             'priceLevel': '$30–50',
             'category': 'Italian restaurant',
             'phoneNumber': '(212) 300-9840',
             'website': 'https://www.lapecorabianca.com/',
             'cid': '6580713665095712525'},
            {'position': 4,
             'title': 'Masseria East',
             'address': '1404 3rd Ave, New York, NY 10075',
             'latitude': 40.774910000000006,
             'longitude': -73.957163,
             'rating': 4.7,
             'ratingCount': 299,
             'priceLevel': '$30–50',
             'category': 'Italian restaurant',
             'phoneNumber': '(212) 535-3520',
             'website': 'http://www.masseriaeast.com/',
             'cid': '1165555394655432498'},
            {'position': 5,
             'title': 'Pavin 86',
             'address': '1663 1st Ave, New York, NY 10028',
             'latitude': 40.777448,
             'longitude': -73.94927679999999,
             'rating': 5,
             'ratingCount': 11,
             'priceLevel': '$20–30',
             'category': 'Italian restaurant',
             'phoneNumber': '(646) 368-1666',
             'cid': '14616385514965614026'},
            {'position': 6,
             'title': 'Piccola Cucina Uptown',
             'address': '106 E 60th St, New York, NY 10022',
             'latitude': 40.7632756,
             'longitude': -73.96896149999999,
             'rating': 4.6,
             'ratingCount': 1900,
             'priceLevel': '$30–50',
             'category': 'Italian restaurant',
             'phoneNumber': '(646) 707-3997',
             'website': 'https://www.piccolacucinagroup.com/',
             'cid': '12569403914342629464'},
            {'position': 7,
             'title': 'La Voglia NYC',
             'address': '1645 3rd Ave, New York, NY 10128',
             'latitude': 40.782702,
             'longitude': -73.95094569999999,
             'rating': 4.4,
             'ratingCount': 360,
             'priceLevel': '$50–100',
             'category': 'Italian restaurant',
             'phoneNumber': '(212) 417-0181',
             'website': 'http://www.lavoglianyc.com/',
             'cid': '1355377864710486791'},
            {'position': 8,
             'title': 'da Adriano',
             'address': '1198 1st Ave, New York, NY 10065',
             'latitude': 40.7631383,
             'longitude': -73.95919169999999,
             'rating': 4.8,
             'ratingCount': 240,
             'priceLevel': '$30–50',
             'category': 'Italian restaurant',
             'phoneNumber': '(646) 371-9412',
             'website': 'http://daadriano.com/',
             'cid': '988704178780025788'},
            {'position': 9,
             'title': 'L’incontro by Rocco',
             'address': '1572 2nd Ave, New York, NY 10028',
             'latitude': 40.7749695,
             'longitude': -73.95354739999999,
             'rating': 4.7,
             'ratingCount': 1400,
             'priceLevel': '$50–100',
             'category': 'Italian restaurant',
             'phoneNumber': '(718) 721-3532',
             'website': 'https://www.lincontrobyrocco.com/',
             'cid': '7698736469939478155'},
            {'position': 10,
             'title': 'Water & Wheat',
             'address': '1379 3rd Ave, New York, NY 10075',
             'latitude': 40.7738747,
             'longitude': -73.9573571,
             'rating': 4.7,
             'ratingCount': 245,
             'priceLevel': '$30–50',
             'category': 'Italian restaurant',
             'phoneNumber': '(646) 484-5054',
             'website': 'http://www.waterandwheatnyc.com/',
             'cid': '14865033522272348854'}],
 'credits': 1}
```
